package com.lanou.timeline;

import redis.clients.jedis.Jedis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Atest {

//        //连接本地的 Redis 服务
//        Jedis jedis = new Jedis("172.16.29.104",6379);
//        System.out.println("连接成功");
//        //设置 redis 字符串数据
//        jedis.set("runoobkey", "www.runoob.com");
//        // 获取存储的数据并输出
//        System.out.println("redis 存储的字符串为: "+ jedis.get("runoobkey"));



        private static final Logger logger = LoggerFactory.getLogger(Atest.class);

        @Autowired
        RedisTemplate redisTemplate;

        @Autowired
        StringRedisTemplate stringRedisTemplate;

        @RequestMapping("/set")
        public void set() {

            redisTemplate.opsForValue().set("test", "4321");
        }

        @RequestMapping("/show")
        public String show(){

            logger.info(redisTemplate.opsForValue().get("test").toString());
            return "Hello World";
        }

}
